//
// Created by 123 on 2025/1/10.
//
#include "algorithm"
#include "vector"
#include "iostream"

void test(){
    std::vector<int> v;
    for (int i = 0; i < 10; ++i) {
        v.push_back(i);
    }

    bool ret = std::binary_search(v.begin(),v.end(),2);
    if(ret){
        std::cout << "got iit " << std::endl;
        //统计次数
        int nums = std::count(v.begin(),v.end(),2);
        std::cout << "nums = " << nums << std::endl;
    }else{
        std::cout << " not found " << std::endl;
    }
}

class Person{
public:
    std::string name;
    int age;
public:
    Person(std::string name,int age){
        this->name = name;
        this->age = age;
    }
    bool operator==(const Person& p){
        if(this->name == p.name && this->age == p.age){
            return true;
        }else{
            return false;
        }
    }
};

void test2(){
    std::vector<Person> v;
    v.push_back(Person("zs",18));
    v.push_back(Person("zs",18));
    v.push_back(Person("ls",20));

    int count =  std::count(v.begin(),v.end(),Person("zs",18));
    std::cout << count << std::endl;
}


int main155(){
    test();
    test2();
    return 0;
}